﻿using Confluent.Kafka;
using Microsoft.Extensions.Logging;

namespace Msung.Core.Extensions
{
    public static class EntityExtension
    {
        /// <summary>  
        /// 根据GUID获取16位的唯一字符串  
        /// </summary>  
        /// <param name="guid"></param>  
        /// <returns></returns>  
        public static string To16String(this Guid guid)
        {
            var i = guid.ToByteArray().Aggregate<byte, long>(1, (current, b) => current * (b + 1));
            return $"{i - DateTime.Now.Ticks:X}";
        }
        
        public static string PrefixTo16String(string prefix)
        {
            var i = Guid.NewGuid().ToByteArray().Aggregate<byte, long>(1, (current, b) => current * (b + 1));
            return $"{prefix}{i - DateTime.Now.Ticks:X}";
        }
       
    }
}
